package org.example.hospital_registration_system.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.hospital_registration_system.model.AppointmentRelation;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface IAppointmentRelationMapper {


    @Select("select relation_id ,doctor_name ,department_name ,appointment_date ,create_time ,status " +
            "from user_doctor_relation " +
            "where user_id = #{userId} and is_deleted=0")
    List<AppointmentRelation> selectByUserId(Integer userId);
    


//    @Select("select relation_id ,doctor_name ,department_name ,appointment_date ,create_time ,status " +
//            "from user_doctor_relation " +
//            "where user_id = #{userId} and is_deleted=0 and status=#{status}")
    List<AppointmentRelation> selectByStatus(Integer userId,Integer status);


    @Select("select relation_id ,doctor_name ,department_name ,appointment_date ,create_time ,status " +
            "from user_doctor_relation " +
            "where user_id = #{userId} and is_deleted=0 and appointment_date=#{appointmentDate}")
    List<AppointmentRelation> selectByData(Integer userId, String appointmentDate);


    @Insert("INSERT INTO user_doctor_relation(user_id,user_name,department_id, department_name, doctor_id, doctor_name, appointment_date, appointment_time) " +
            "VALUES(#{userId},#{userName},#{departmentId}, #{departmentName}, #{doctorId}, #{doctorName}, #{appointmentDate}, #{appointmentTime})")
    Integer insertRelation(AppointmentRelation appointmentRelation);


    @Update("UPDATE user_doctor_relation SET is_deleted = 1 WHERE relation_id = #{relationId}")
    Integer deleteRelation(Integer relationId);
}
